import {defineStore} from "pinia";
import {
    reqBookingScheduleRule,
    reqDoctorInfo,
    reqFindScheduleList,
    reqHospitalDepartment,
    reqHospitalDetail
} from "@/api/hospital";
let useHospitalDetailStore = defineStore('Ddetail',{
    state: () => {
        return {
            hospitalInfo:{},
            hospitalDepartment:[],
            BookingScheduleRule:[],
            FindScheduleList:[],
            doctorInfo:{},
        }
    },
    actions:{
        async getHospital(hoscode:string){
            let result = await reqHospitalDetail(hoscode);
            if (result.code == 200) {
                this.hospitalInfo = result.data
            }else {
                throw Error(result.message)
            }
        },
        async getHospitalDepartment(hoscode:string){
            let result = await reqHospitalDepartment(hoscode);
            if (result.code == 200) {
                this.hospitalDepartment = result.data
            }else {
                throw Error(result.message)
            }
        },
        async getBookingScheduleRule(data:any){
            let result = await reqBookingScheduleRule(data);
            if (result.code == 200) {
                this.BookingScheduleRule = result.data
                return 'ok';
            }else {
                throw Error(result.message)
            }
        },
        async getFindScheduleList(hoscode:string,depcode:string,workDate:string){
            let result = await reqFindScheduleList(hoscode,depcode,workDate);
            if (result.code == 200) {
                this.FindScheduleList = result.data
                return 'ok';
            }else {
                throw Error(result.message)
            }
        },
        async getDoctorInfo(docId:string){
            let result = await reqDoctorInfo(docId);
            if (result.code == 200) {
                this.doctorInfo = result.data
                return 'ok';
            }else {
                throw Error(result.message)
            }
        },



    },
    getters:{

    }
})

export default useHospitalDetailStore;